<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/6/22 0022
  Time: 下午 7:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
    <title>发布</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/app.css"/>
    <link rel="stylesheet" type="text/css" href="css/addFarm.css">
</head>
<body>
<div id="return">
    <div id="return_layout">
        <a href="user.jsp"><p class="glyphicon glyphicon-chevron-left"></p></a>
        <a href="user.jsp">返回</a>
    </div>
    <p id="text_myInformation">发布</p>
</div>

<form method="POST" action="#">
    <div id="card">
        <div id="user_infor1">
            <input type="text" id="farm_name" name="farm_name" placeholder="请输入农场名称" onblur="checkName()"/>
            <span id="farm_name_prompt"></span>

            <input class="input" type="text" id="farm_price" name="farm_price" placeholder="请输入农场价格"
                   onblur="checkPrice()"/>
            <span id="farm_price_prompt"></span>

            <input class="input" type="text" id="farm_type" name="farm_type" placeholder="请输入可种植类型"
                   onblur="checkType()"/>
            <span id="farm_type_prompt"></span>

            <input class="input" type="text" id="farm_eggs" name="farm_eggs" placeholder="请输入鸡蛋产量"/>

            <input class="input" type="text" id="farm_people" name="farm_bed" placeholder="请输入已种植类型"/>

            <input class="input" type="text" id="farm_area" name="farm_area" placeholder="请输入农场地址"
                   onblur="checkArea()"/>
            <span id="farm_area_prompt"></span>

            <input type="file" name="image" multiple id="file_img"/>
            <input class="input" type="submit" name="text_submit" value="发布" id="text_submit">
        </div>
    </div>
</form>


</body>
<script type="text/javascript">
    function $(elementId) {
        return document.getElementById(elementId).value;
    }

    function divId(elementId) {
        return document.getElementById(elementId);
    }

    function checkName() {
        var user = $("farm_name");
        var userId = divId("farm_name_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "名称不能为空！";
            return false;
        }
        return true;
    }

    function checkPrice() {
        var user = $("farm_price");
        var userId = divId("farm_price_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "价格不能为空！";
            return false;
        }
        return true;
    }

    function checkType() {
        var user = $("farm_type");
        var userId = divId("farm_type_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "类型不能为空！";
            return false;
        }
        return true;
    }

    function checkPeople() {
        var user = $("farm_people");
        var userId = divId("farm_people_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "人数不能为空！";
            return false;
        }
        return true;
    }

    function checkArea() {
        var user = $("farm_area");
        var userId = divId("farm_area_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "地址不能为空！";
            return false;
        }
        return true;
    }

    function checkIntroduce() {
        var user = $("farm_introduce");
        var userId = divId("farm_introduce_prompt");
        userId.innerHTML = "";
        var reg = /\S/;
        if (reg.test(user) == false) {
            userId.innerHTML = "名称不能为空！";
            return false;
        }
        return true;
    }
</script>
</html>